/***
 * Excerpted from "Stripes: and Java Web Development is Fun Again",
 * published by The Pragmatic Bookshelf.
 * Copyrights apply to this code. It may not be used to create training material, 
 * courses, books, articles, and the like. Contact us if you are in doubt.
 * We make no guarantees that this code is fit for any purpose. 
 * Visit http://www.pragmaticprogrammer.com/titles/fdstr for more book information.
***/
package stripesbook.ext.init;

import org.stripesstuff.stripersist.StripersistInit;
import stripesbook.dao.RoleDao;
import stripesbook.dao.impl.stripersist.RoleDaoImpl;
import stripesbook.model.Role;

public class DataInit implements StripersistInit {
    private RoleDao roleDao = new RoleDaoImpl();

    public void init() {
        if (roleDao.read().isEmpty()) {
            roleDao.save(new Role("User"));
            roleDao.save(new Role("Administrator"));
            roleDao.commit();
        }
    }
}
